package com.ruoyi.intelligence.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.intelligence.domain.SysTesting;
import com.ruoyi.intelligence.service.ISysTestingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检测列表Controller
 * 
 * @author wenkai
 * @date 2020-08-27
 */
@RestController
@RequestMapping("/intelligence/testing")
public class SysTestingController extends BaseController
{
    @Autowired
    private ISysTestingService sysTestingService;

    /**
     * 查询检测列表列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:testing:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysTesting sysTesting)
    {
        startPage();
        List<SysTesting> list = sysTestingService.selectSysTestingList(sysTesting);
        return getDataTable(list);
    }

    /**
     * 导出检测列表列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:testing:export')")
    @Log(title = "检测列表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysTesting sysTesting)
    {
        List<SysTesting> list = sysTestingService.selectSysTestingList(sysTesting);
        ExcelUtil<SysTesting> util = new ExcelUtil<SysTesting>(SysTesting.class);
        return util.exportExcel(list, "testing");
    }

    /**
     * 获取检测列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('intelligence:testing:query')")
    @GetMapping(value = "/{testingId}")
    public AjaxResult getInfo(@PathVariable("testingId") Long testingId)
    {
        return AjaxResult.success(sysTestingService.selectSysTestingById(testingId));
    }

    /**
     * 新增检测列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:testing:add')")
    @Log(title = "检测列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysTesting sysTesting)
    {
        return toAjax(sysTestingService.insertSysTesting(sysTesting));
    }

    /**
     * 修改检测列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:testing:edit')")
    @Log(title = "检测列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysTesting sysTesting)
    {
        return toAjax(sysTestingService.updateSysTesting(sysTesting));
    }

    /**
     * 删除检测列表
     */
    @PreAuthorize("@ss.hasPermi('intelligence:testing:remove')")
    @Log(title = "检测列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{testingIds}")
    public AjaxResult remove(@PathVariable Long[] testingIds)
    {
        return toAjax(sysTestingService.deleteSysTestingByIds(testingIds));
    }
}
